package com.deer.wms.base.system.web.zhBusiness.work;

import com.deer.wms.base.system.model.bill.*;
import com.deer.wms.base.system.model.box.BoxItem;
import com.deer.wms.base.system.model.box.BoxItemDto;
import com.deer.wms.base.system.model.item.ItemInfo;
import com.deer.wms.base.system.model.task.*;
import com.deer.wms.base.system.model.ware.CellInfo;
import com.deer.wms.base.system.model.zh.WorkTasks;
import com.deer.wms.base.system.service.bill.BillInSapService;
import com.deer.wms.base.system.service.bill.IBillInMasterService;
import com.deer.wms.base.system.service.box.IBoxItemService;
import com.deer.wms.base.system.service.item.IItemInfoService;
import com.deer.wms.base.system.service.zh.WorkTasksService;
import com.deer.wms.base.system.util.JedisServiceUtil;
import com.deer.wms.common.core.result.CommonCode;
import com.deer.wms.common.core.result.Result;
import com.deer.wms.common.core.result.ResultGenerator;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**入库工作任务*/
@RestController
@RequestMapping("/billInTasks")
@Slf4j
public class BillInTasksController {
    @Autowired //工作任务
    private WorkTasksService workTasksService;
    @Autowired //入库单
    private IBillInMasterService iBillInMasterService;
    @Autowired //库存
    private IBoxItemService iBoxItemService;
    @Autowired //sap
    private BillInSapService billInSapService;
    @Autowired
    private IItemInfoService iItemInfoService;


    /**手持机扫码 收到:物料信息+入库单id 返回:作业创建结果+创建任务号*/
    @PostMapping("/sendBillInDetail")
    @ResponseBody
    @Transactional
    public Result sendBillInDetail(String json){
        List<WorkTasks> workTaskList = new Gson().fromJson(json, new TypeToken<List<WorkTasks>>(){}.getType());

        /*判断Msg里唯一流水批号是否重复,如果重复则返回异常*/
        String strMsg;
        Float weight = 0f; //托盘总重量
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date makeDate = null;
        for (WorkTasks workTasks : workTaskList) {
            strMsg = workTasks.getMsg();
            String[] msg = strMsg.split(",");
            Float msg3 = Float.parseFloat(msg[3].replaceAll("[a-zA-Z]", ""));
            String strBatchCode = msg[4].replaceAll("[a-zA-Z]", "").substring(0,10);
            String strTime = "20"+ msg[4].replaceAll("[a-zA-Z]", "").substring(0,2)+//年
                    "-"+ msg[4].replaceAll("[a-zA-Z]", "").substring(2,4)+//月
                    "-"+msg[4].replaceAll("[a-zA-Z]", "").substring(4,6);//日
            try {
                makeDate =sdf.parse(strTime);
            } catch (ParseException e) {
                e.printStackTrace();
            }
            workTasks.setSupplierName(msg[0])
                    .setItemCode(msg[1]) //物料号
                    .setItemName(msg[2]) //物料描述
                    .setWeight(msg3) //重量
                    .setBatchCode(strBatchCode) //批次
                    .setMakeTime(makeDate)//生产日期
                    .setBatch(msg[4]); //流水批号

            List<String > repeatBatch = workTasksService.findDetailItemByBatch(workTasks);
            if(!repeatBatch.isEmpty()){
                return ResultGenerator.genFailResult(CommonCode.ITEMCODE_ERROR);
            }
            weight = weight + workTasks.getWeight();

        }

        /*查询是否有对应SAP采购单 根据billId查询ItemCode(MATNR)*/
        float height = 0f; //单卷高度
        Integer itemId = 0;
//        Integer supplierId =0;
//        String supplierName = "";
//        if(workTaskList.get(0).getType() < 4){ //4试做品 5紧急
        List<BillInMaster> billInMasterList = iBillInMasterService.findBillInMasterByItemCode(workTaskList.get(0));
            if(billInMasterList.isEmpty()){
            return ResultGenerator.genFailResult(CommonCode.ZHPDABILLIN_ERROR);
            }
//            supplierId = billInMasterList.get(0).getSupplierId();
//            supplierName = billInMasterList.get(0).getSupplierName();
            itemId = billInMasterList.get(0).getItemId();
            height = billInMasterList.get(0).getHeight();
//        }else {
//            ItemInfo itemInfo = iItemInfoService.findByItemCode(workTaskList.get(0).getItemCode());
//
//            itemId = itemInfo.getItemId();
//            height = itemInfo.getHeight();
//        }
        SimpleDateFormat date = new SimpleDateFormat("yyyyMMddHHmmss");
        //创建托盘码
        String boxCode = "BOX"+date.format(new Date());

        /*1.新增入库作业*/
        TaskInfo taskInfo = new TaskInfo();
        taskInfo.setType(1) //1-入库
                .setState(1)//1-已下发
                .setBoxCode(boxCode)//托盘码
                .setStartPosition("入库站台") //开始位置
                .setEndPosition("入库站台") //当前位置
                .setCreateUserName(workTaskList.get(0).getCreateUserName());//操作人
        workTasksService.insertBillInWorkTasks(taskInfo);

        /*2.新增入库明细的物料信息*/
        BillInDetail billInDetail = new BillInDetail();
        billInDetail.setTaskId(taskInfo.getId()) //任务id
                .setItemCode(workTaskList.get(0).getItemCode())//物料编码
                .setItemId(itemId)//物料id
                .setBatch(workTaskList.get(0).getBatchCode())  //批次
                .setSupplierName(workTaskList.get(0).getSupplierName())
                .setBoxCode(boxCode)//托盘码
                .setWeight(weight)//重量总和
                .setMakeTimeIn(workTaskList.get(0).getMakeTime()) //生产日期
                .setBillId(workTaskList.get(0).getBillId()); //入库单号

        if(workTaskList.get(0).getType() == 4){
            billInDetail.setBillInState(5);//试做品
        }else {
            billInDetail.setBillInState(1);//合格品
        }
        iBillInMasterService.insertBillInDetail(billInDetail);
        workTasksService.saveDetailId(taskInfo.getId(),billInDetail.getBillInDetailId());

        //作业任务添加明细id
        iBillInMasterService.saveInDetailId(taskInfo.getId(),billInDetail.getBillInDetailId());
        /*3.新增虚拟托盘*/
        BoxItem boxItem = new BoxItem();
        boxItem.setBillInDetailId(billInDetail.getBillInDetailId())
                .setWeight(weight) //整托重量
                .setBoxCode(boxCode) //托盘码
                .setBatch(workTaskList.get(0).getBatchCode());  //批次
        iBoxItemService.insertBoxItem(boxItem);

        /*4.新增托盘明细(每卷的信息)*/
        BillInDetailItem billInDetailItem = new BillInDetailItem();
        float heights = 0f; // 总高度
        for (WorkTasks detailItem : workTaskList) {
            billInDetailItem.setItemCode(detailItem.getItemCode())//物料编码
                    .setWeight(detailItem.getWeight())//重量
                    .setBatch(detailItem.getBatch())//批次
                    .setBillInDetailId(billInDetail.getBillInDetailId());//id
            heights = heights + height;
            iBillInMasterService.insertBillInDetailItem(billInDetailItem);

        }
        /*添加高度*/
        billInDetail.setHeight(heights);
        iBillInMasterService.saveBillInDetailHeight(billInDetail);

        return ResultGenerator.genFailResult(CommonCode.WS_SUCCESS);
    }

    /**自动扫码  收到唯一流水批号 ,记录开始作业时间,返回任务号*/
    @PostMapping("/sendTaskNumber")
    @ResponseBody
    @Transactional
    public Result sendTaskNumber(@RequestBody RequestBatch requestBatch){
        //创建任务号
        long taskNumber = workTasksService.getTaskNumber();

        //没扫到码
        if(requestBatch.getItemcode() == null||requestBatch.getItemcode().equals("[]")){
            return  ResultGenerator.genBillSuccessResult(null,taskNumber,"条码未扫到");
        }
        //获取条码
        List<String> strMsg = null;
        try {
            strMsg = new Gson().fromJson(requestBatch.getItemcode(), new TypeToken<List<String>>(){}.getType());
        } catch (JsonSyntaxException e) {
            return  ResultGenerator.genBillSuccessResult(null,taskNumber,"条码未扫到");
        }

        if(strMsg==null||strMsg.size()==0){
             return  ResultGenerator.genBillSuccessResult(null,taskNumber,"条码未扫到");
         }
        String[] msg = strMsg.get(0).split(",");
        WorkTasks workTasks = new WorkTasks();
        Float msg3 = null;
        try {
            msg3 = Float.parseFloat(msg[3].replaceAll("[a-zA-Z]", ""));
        } catch (NumberFormatException e) {
            return  ResultGenerator.genBillSuccessResult(null,taskNumber,"条码未扫到");
        }
        try {
            workTasks.setItemCode(msg[1]) //物料号
                    .setItemName(msg[2]) //物料描述
                    .setWeight(msg3) //重量
                    .setBatch(msg[4]); //唯一批号
        } catch (Exception e) {
            return  ResultGenerator.genBillSuccessResult(null,taskNumber,"条码未扫到");
        }

        //根据唯一流水号查询对应任务
        List<TaskInfoDto> taskInfoList = workTasksService.findTaskWorkByBatch(workTasks);
        if(taskInfoList.size() > 1 ){
            return  ResultGenerator.genBillSuccessResult(null,taskNumber,"条码已加入任务,请处理重复任务");
        }
        if(taskInfoList.size() == 0 ){
            return  ResultGenerator.genBillSuccessResult(null,taskNumber,"入库任务中无此条码");
        }
        //添加任务信息
        taskInfoList.get(0).setState(2)//2-执行中+++++++++
                .setTaskNumber(taskNumber) //任务号
                .setEndPosition("扫码点");
        workTasksService.saveBillInWorkTasksById(taskInfoList.get(0));

        return  ResultGenerator.genBillSuccessResult(workTasks.getBatch(),taskInfoList.get(0).getTaskNumber(),"成功");
    }


    /**自动称重 收到任务号+重量 返回核对结果&库位*/
    @PostMapping("/allocationCell")
    @ResponseBody
    @Transactional
    public Result allocationCell(@RequestBody RequestWeight requestWeight){

        WorkTasks workTasks = new WorkTasks();
        workTasks.setWeightReceived(requestWeight.getWeightReceived());
        workTasks.setTaskNumber(requestWeight.getTaskNumber());

        /*异常-1 根据查询任务号,如果任务号空,说明扫码未绑定,去异常口*/
        List<BillInDetailDto> billInDetailList = iBillInMasterService.selectBillInDetailByTaskNumber(workTasks.getTaskNumber());
        if(billInDetailList.size() == 0){
            return  ResultGenerator.genBillSuccessResult(0,workTasks.getTaskNumber(),"2",0,0F,"PDA未绑定");
        }
        BillInDetailDto billInDetail = billInDetailList.get(0);
        //添加称重重量
        billInDetail.setWeightReceived(requestWeight.getWeightReceived());
        iBillInMasterService.saveBillInDetail(billInDetail);
        /*异常-2 实际重量和条码重量对比*/
        List<BillInDetailDto> detailWeightList = iBillInMasterService.selectBillInDetailByTaskNumber(workTasks.getTaskNumber());
        BillInDetailDto detailWeight = detailWeightList.get(0);

        if(detailWeight.getWeight() + 20F < (workTasks.getWeightReceived())
                || detailWeight.getWeight() - 20F > workTasks.getWeightReceived()){
           return  ResultGenerator.genBillSuccessResult(0,workTasks.getTaskNumber(),"2",0,detailWeight.getWeight(),"重量不匹配");
       }

        /*根据大小分配货位*/
        Float height = detailWeight.getHeight();
        int i = 0;
        String cellCode;
        List<CellInfo> cellCodeList;
        //查所有库位
        //cellCodeList = workTasksService.selectCellCodeFrom();
        if(height > 450){
            i = 0;
            return  ResultGenerator.genBillSuccessResult(0,workTasks.getTaskNumber(),"2",i,detailWeight.getWeight(),"高度超过400,禁止入库");
        }
        if(height < 200){
            //查低货位 小于 200
            i = 1;
            cellCodeList = workTasksService.selectCellCodeFromLittle();
            //如果中间层满,分配最高层
            if(cellCodeList.isEmpty()){
                cellCodeList = workTasksService.selectCellCodeFromHeight();
            }
        }else {
            //查高货位(一层) 大于 200
            i = 2;
            cellCodeList = workTasksService.selectCellCodeFromBig();
            //如果1层满,分配最高层
            if(cellCodeList.isEmpty()){
                cellCodeList = workTasksService.selectCellCodeFromHeight();
            }

        }
        /*异常-3 货位满,无法分配货位*/
        if(cellCodeList.isEmpty()){
            return  ResultGenerator.genBillSuccessResult(0,workTasks.getTaskNumber(),"2",0,detailWeight.getWeight(),"货位满");
        }

        cellCode = cellCodeList.get(0).getCellCode();//货位
        TaskInfo taskInfo = new TaskInfo();
        taskInfo.setCellId(cellCodeList.get(0).getCellId())
                .setTaskNumber(workTasks.getTaskNumber())
                .setEndPosition("称重台");
        //保存库位到入库作业
        workTasksService.saveWorkTaskByTaskNumber(taskInfo);
        //保存库位到托盘
        iBoxItemService.saveBoxItemByTaskNumber(taskInfo);
        //更改库位状态为 入库中 3
        workTasksService.saveCell3(taskInfo.getCellId());
        //1正常 2去异常口   1低  2高  0无
        return  ResultGenerator.genBillSuccessResult(cellCode,workTasks.getTaskNumber(),"1",i,detailWeight.getWeight(),"货位分配成功");
    }

    /**收到成功消息(任务号),改变库存*/
    @PostMapping("/carriageResult")
    @ResponseBody
    @Transactional
    public Result carriageResult(@RequestBody RequestRepertory requestRepertory){
        //{"taskNumber":"92400001"}
        WorkTasks workTasks = new WorkTasks();
        workTasks.setTaskNumber(requestRepertory.getTaskNumber());

        if(workTasks.getTaskNumber() == null ){
            return ResultGenerator.genFailResult(CommonCode.TASKNUMBER_ERROR);
        }

        /*更改任务工作状态 4-已完成 ,添加结束时间,更改位置*/
        TaskInfo taskInfo = new TaskInfo();
        taskInfo.setState(4)
                .setTaskNumber(workTasks.getTaskNumber())
                .setEndPosition("立体库");
        workTasksService.saveWorkTaskByTaskNumber(taskInfo);

        //获取 itemId
        int itemId = workTasksService.findItemId(workTasks.getTaskNumber());
        workTasks.setItemId(itemId);
        /*更改 1.货位状态 2.托盘状态 3.SAP*/
        BoxItemDto boxItem = iBoxItemService.findBoxItemMsgByTaskNumber(workTasks);
        workTasksService.saveCell1(boxItem.getCellId());
        //改变库存状态
        if(boxItem.getType() < 4 || boxItem.getBillState() != 1){
            //正常入库或已审核特殊入库  解冻库存
            iBoxItemService.unfreezeBoxItem(boxItem.getId());
        }else {
            //特殊入库冻结库存
            iBoxItemService.blockedBoxItem(boxItem.getId());
        }
        workTasks.setBillInSapDetailId(boxItem.getBillInSapDetailId());
        workTasks.setWeight(boxItem.getWeight());
        //改变SAP明细已入库数量 (标签重量)
        billInSapService.updateBillInSapDetail(workTasks);
        //改变SAP明细为部分收货
        BillInSapDetail billInSapDetail = new BillInSapDetail();
        billInSapDetail.setReceiptState(2).setBillInSapDetailId(boxItem.getBillInSapDetailId());
        billInSapService.updateBillInSapDetailReceiptState(billInSapDetail);
        //改变入库单为部分入库
        BillInMaster billInMaster = new BillInMaster();
        billInMaster.setState(2).setBillId(boxItem.getBillId());
        iBillInMasterService.updateBillInMaster(billInMaster);

        /*判断SAP是否已完成*/
        List<BillInSapDetail> detailList = billInSapService.findSapDetailById(workTasks.getBillInSapDetailId());
        BillInSapDetail detail = detailList.get(0);
        if(detail.getERFMG_RECEIVED()>= detail.getERFMG()){
            //如果超出预定数量则明细 3已收货
            billInSapDetail.setReceiptState(3).setBillInSapDetailId(boxItem.getBillInSapDetailId());
            billInSapService.updateBillInSapDetailReceiptState(billInSapDetail);
            billInSapDetail.setBillInSapId(boxItem.getBillInSapId());
            //判断对应的SAP单,如果全部完成,则 入库单 已完成
            if(billInSapService.findBillInSapOver(billInSapDetail) == 0) {
                billInMaster.setState(3);//入库单入库完成
                iBillInMasterService.updateBillInMaster(billInMaster);
            }
        }
        return  ResultGenerator.genBillSuccessResult(null,workTasks.getTaskNumber(),"成功");

    }

    /**手持机异常口处理(扫物料条码处理异常)*/
    @PostMapping("/fixBox")
    @ResponseBody
    @Transactional
    public Result fixBox(String json){
        List<WorkTasks> workTaskList = new Gson().fromJson(json, new TypeToken<List<WorkTasks>>(){}.getType());

        //获取任务
        String strMsg;
        TaskInfoDto taskInfo = new TaskInfoDto();
        for (WorkTasks workTask : workTaskList) {
            strMsg = workTask.getMsg();
            String[] msg = strMsg.split(",");
            workTask.setBatch(msg[4]);
            List<TaskInfoDto> taskInfoDtoList = workTasksService.findTaskWorkByBatch(workTask);
            if(taskInfoDtoList.size() != 0 ){
                taskInfo = taskInfoDtoList.get(0);
                break;
            }
        }
        if(taskInfo.getBatch() == null){
            return ResultGenerator.genFailResult(CommonCode.BILLNO_ERROR);
        }
        //1.任务改为异常状态
        WorkTasks workTasks = new WorkTasks();
        workTasks.setState(3)
                .setBatch(taskInfo.getBatch());
        workTasksService.updateStateByBatch(workTasks);

        //2.根据条码,修改信息
        //--1修改钢卷
        iBillInMasterService.deleteBillInDetailItemById(taskInfo.getBillInDetailId());
        BillInDetailItem billInDetailItem = new BillInDetailItem();
        Float heights = 0f; // 总高度
        Float weights = 0f; // 总重量
        Float msg3 = 0f;//单卷重
        String[] msg; //条码
        for (WorkTasks detailItem : workTaskList) {
            msg = detailItem.getMsg().split(",");
            msg3 = Float.parseFloat(msg[3].replaceAll("[a-zA-Z]", ""));
            billInDetailItem.setItemCode(msg[1])//物料编码
                    .setWeight(msg3)//重量
                    .setBatch(msg[4])//批号
                    .setBillInDetailId(taskInfo.getBillInDetailId());//id
            heights = heights + taskInfo.getHeight();
            weights = weights + msg3;
            iBillInMasterService.insertBillInDetailItem(billInDetailItem);
        }

        //--2修改明细重量和高度
        BillInDetail billInDetail = new BillInDetail();
        billInDetail.setBillInDetailId(taskInfo.getBillInDetailId())
                .setWeight(weights)
                .setHeight(heights);
        iBillInMasterService.updateBillInDetail(billInDetail);
        //--3修改托盘重量
        BoxItem boxItem = new BoxItem();
        boxItem.setWeight(weights)
                .setBillInDetailId(taskInfo.getBillInDetailId());
        iBoxItemService.updatetBoxItemByDetailId(boxItem);

        return ResultGenerator.genFailResult(CommonCode.WS_SUCCESS);
    }

    /**异常口分配货位&任务号*/
    @PostMapping("/fixBoxAllocationCell")
    @ResponseBody
    @Transactional
    public Result fixBoxAllocationCell(@RequestBody RequestRepertory requestRepertory){
        WorkTasks workTasks = new WorkTasks();
        workTasks.setTaskNumber(requestRepertory.getTaskNumber());

        //唯一的异常任务添加任务号
        workTasksService.updateTaskNumber(workTasks.getTaskNumber());
        //获取任务上托盘数据(高度)
        BillInDetailDto billInDetail = iBillInMasterService.selectHeightByTaskNumber(workTasks.getTaskNumber());

        //根据高度,分配货位
        Float height = billInDetail.getHeight();
        Float weight = billInDetail.getWeight();
        String cellCode;
        List<CellInfo> cellCodeList;
        //查所有库位
        //cellCodeList = workTasksService.selectCellCodeFrom();
        int i = 2;
        if(height > 450){
            return  ResultGenerator.genBillSuccessResult(0,workTasks.getTaskNumber(),"2",0,weight,"高度超过400,禁止入库");
        }
        if(height < 200){
            //查低货位 小于 200
            i=1;
            cellCodeList = workTasksService.selectCellCodeFromLittle();
            //如果中间层满,分配最高层
            if(cellCodeList.isEmpty()){
                cellCodeList = workTasksService.selectCellCodeFromHeight();
            }
        }else {
            //查高货位(一层) 大于 200
            i=2;
            cellCodeList = workTasksService.selectCellCodeFromBig();
            //如果1层满,分配最高层
            if(cellCodeList.isEmpty()){
                cellCodeList = workTasksService.selectCellCodeFromHeight();
            }
        }
        //货位满
        if(cellCodeList.isEmpty()){
            return  ResultGenerator.genBillSuccessResult(0,workTasks.getTaskNumber(),"2",0,weight,"货位满");
        }

        cellCode = cellCodeList.get(0).getCellCode();//货位
        TaskInfo taskInfo = new TaskInfo();
        taskInfo.setTaskNumber(workTasks.getTaskNumber())
                .setState(2)//任务执行中
                .setCellId(cellCodeList.get(0).getCellId());
        //保存库位到入库作业
        workTasksService.saveWorkTaskByTaskNumber(taskInfo);
        //保存库位到托盘
        iBoxItemService.saveBoxItemByTaskNumber(taskInfo);
        //更改库位状态为 入库中 3
        workTasksService.saveCell3(taskInfo.getCellId());
        //1正常 2去异常口   1低  2高  0无
        return  ResultGenerator.genBillSuccessResult(cellCode,workTasks.getTaskNumber(),"1",i,weight,"成功");
    }

    /**生产退料入库*/
    @PostMapping("/backBoxAllocationCell")
    @ResponseBody
    @Transactional
    public Result backBoxAllocationCell(@RequestBody RequestRepertory requestRepertory){

        //创建任务号
        long taskNumber = workTasksService.getTaskNumber();
        WorkTasks workTasks = new WorkTasks();
        workTasks.setTaskNumber(taskNumber);
        //唯一的异常任务添加任务号
        workTasksService.updateTaskNumber(workTasks.getTaskNumber());
        //获取任务上托盘数据(高度)
        BillInDetailDto billInDetail = iBillInMasterService.selectHeightByTaskNumber(workTasks.getTaskNumber());

        //根据高度,分配货位
        Float height = billInDetail.getHeight();
        Float weight = billInDetail.getWeight();
        String cellCode;
        List<CellInfo> cellCodeList;
        //查所有库位
        //cellCodeList = workTasksService.selectCellCodeFrom();
        int i = 2;
        if(height > 450){
            return  ResultGenerator.genBillSuccessResult(0,workTasks.getTaskNumber(),"2",0,weight,"高度超过400,禁止入库");
        }
        if(height < 200){
            //查低货位 小于 200
            cellCodeList = workTasksService.selectCellCodeFromLittle();
            i=1;
        }else {
            //查高货位(一层) 大于 200
            i=2;
            cellCodeList = workTasksService.selectCellCodeFromBig();
            //如果1层满,分配最高层
            if(cellCodeList.isEmpty()){
                cellCodeList = workTasksService.selectCellCodeFromHeight();
            }
        }
        //货位满
        if(cellCodeList.isEmpty()){
            return  ResultGenerator.genBillSuccessResult(0,workTasks.getTaskNumber(),"2",0,weight,"货位满");
        }

        cellCode = cellCodeList.get(0).getCellCode();//货位
        TaskInfo taskInfo = new TaskInfo();
        taskInfo.setTaskNumber(workTasks.getTaskNumber())
                .setState(2)//任务执行中
                .setCellId(cellCodeList.get(0).getCellId());
        //保存库位到入库作业
        workTasksService.saveWorkTaskByTaskNumber(taskInfo);
        //保存库位到托盘
        iBoxItemService.saveBoxItemByTaskNumber(taskInfo);
        //更改库位状态为 入库中 3
        workTasksService.saveCell3(taskInfo.getCellId());
        //1正常 2去异常口   1低  2高  0无
        return  ResultGenerator.genBillSuccessResult(cellCode,workTasks.getTaskNumber(),"1",i,weight,"成功");
    }




}
